<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改元素属性</title>
</head>
<body>
<div id="change" class="change">
    <a data-bind:href="https://www.baidu.com">有问题，百度一下</a>
</div>

<script>
  let element = document.querySelector("#change > a");
  let attributeNames = element.getAttributeNames();
  // attributeNames.forEach(item => console.log(item))
  for (const attribute of attributeNames) {
      // console.log(attribute);
      let index = attribute.indexOf(":");
      console.log(index);
      // 获取属性名
      let name = attribute.substring(index+1);
      // console.log(name);

      // 获取属性值
      let value = element.getAttribute(attribute);
      // console.log(value);

      element.setAttribute(name, value)

      element.removeAttribute(attribute)

  }
</script>
</body>
</html>